# Maintainer: David Runge <dvzrv@archlinux.org>
# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Eric Bélanger <eric@archlinux.org>

pkgname=quodlibet
pkgver=4.5.0
pkgrel=3
pkgdesc="Music player and music library manager"
arch=(any)
url="https://quodlibet.readthedocs.io/"
license=(GPL2)
depends=(dbus-python gtk3 libsoup python-cairo python-feedparser python-gobject python-mutagen)
makedepends=(python-sphinx_rtd_theme)
# python-raven python-senf are currently vendored
checkdepends=(gst-plugins-base gst-plugins-good python-pytest python-xvfbwrapper)
optdepends=('gst-libav: Extra media codecs for the GStreamer backend'
            'gst-plugins-bad: Extra media codecs for the GStreamer backend; Audio Pitch / Speed, Crossfeed, Submit Acoustic Fingerprints plugins'
            'gst-plugins-base: Default audio backend'
            'gst-plugins-good: Extra media codecs, PulseAudio support for the GStreamer backend; Audio Compressor, Karaoke, Replay Gain plugins'
            'gst-plugins-ugly: Extra media codecs for the GStreamer backend'
            'gtksourceview3: Undo and redo support in multiline text fields'
            'kakasi: Kana/Kanji Simple Inverter plugin'
            'libappindicator-gtk3: Appindicator support in the Tray Icon plugin'
            'libkeybinder3: Multimedia key support under non Gnome setups'
            'libmodplug: MOD support'
            'python-musicbrainzngs: MusicBrainz Lookup, MusicBrainz Sync plugins'
            'python-paho-mqtt: MQTT Publisher plugin'
            'python-pyinotify: Automatic Library Update plugin'
            'rygel: UPnP AV Media Server plugin'
            'webkit2gtk: Web Lyrics plugin'
            'xine-lib: Alternative audio backend')
source=("https://github.com/${pkgname}/${pkgname}/releases/download/release-${pkgver}/${pkgname}-${pkgver}.tar.gz"{,.sig})
sha256sums=('301615829f652cbafedb35539237162a58bc1ee71a567d249f7789d9268245bc'
            'SKIP')
validpgpkeys=(0EBF782C5D53F7E5FB02A66746BD761F7A49B0EC) # Christoph Reiter <reiter.christoph@gmail.com>

prepare() {
  cd ${pkgname}-${pkgver}
  # Fix zsh completions dir
  sed -e 's|vendor-completions|site-functions|' -i gdist/zsh_completions.py
}

build() {
  cd ${pkgname}-${pkgver}
  python setup.py build
}

check() {
  cd ${pkgname}-${pkgver}
  export PYTHONPATH="${PWD}/build"
  # not running useless linter checks
  # TOperonEdit.test_remove_all: https://github.com/quodlibet/quodlibet/issues/3966
  # TCoverManager.test_invalid_glob: https://github.com/quodlibet/quodlibet/issues/4021
  pytest -v --color=yes -k 'not TFlake8' \
    --deselect tests/test_operon.py::TOperonEdit::test_remove_all \
    --deselect tests/test_util_cover.py::TCoverManager::test_invalid_glob
}

package() {
  cd ${pkgname}-${pkgver}
  python setup.py install --root="${pkgdir}" --optimize=1
  install -vDm 644 {README,NEWS}.rst -t "${pkgdir}"/usr/share/doc/${pkgname}
}
